import request from '@/utils/request'
import qs from 'qs'

// 获取商品列表
export function commodityList(data) {
  return request({
    url: '/commodity/listCommodity',
    method: 'post',
    params: data
  })
}

// 删除商品
export function deleteCommodity(data) {
  return request({
    url: '/commodity/delCommodity',
    method: 'post',
    data: qs.stringify(data)
  })
}

// 用于获取商品关联门店的列表
export function linkShopList(data) {
  return request({
    url: '/commodity/linkShopList',
    method: 'post',
    params: data
  })
}

// 新增/编辑商品
export function addCommodity(data) {
  return request({
    url: '/commodity/addCommodity',
    method: 'post',
    data
  })
}

// 更新商品上下架状态
export function changeState(data) {
  return request({
    url: '/commodity/changeState',
    method: 'post',
    data: qs.stringify(data)
  })
}

// 增加多个该商品的运营门店
export function addLinkShop(data) {
  return request({
    url: '/commodity/addLinkShop',
    method: 'post',
    data
  })
}

// 取消关联该门店
export function unlinkShop(data) {
  return request({
    url: '/commodity/unlinkShop',
    method: 'post',
    params: data
  })
}

// 加载商品设置信息
export function getRentDescription(data) {
  return request({
    url: '/commodity/getRentDescription',
    method: 'post',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params: data
  })
}

// 租赁/出售说明设置
export function setRentDescription(data) {
  return request({
    url: '/commodity/setRentDescription',
    method: 'post',
    data
  })
}

// 商品分类
export function getCommodityCategoryList(data) {
  return request({
    url: '/commodity/categoryList',
    method: 'post',
    data
  })
}

// 商品详情
export function getInfoById(data) {
  return request({
    url: '/commodity/commodityDetail',
    method: 'post',
    params: data
  })
}

// 增加多个该商品的运营门店
export function postLinkShop(data) {
  return request({
    url: '/commodity/linkShops',
    method: 'post',
    data
  })
}

// 编辑该商品的运营门店
export function postEditShop(data) {
  return request({
    url: '/commodity/addLinkShop',
    method: 'post',
    data
  })
}

// 门店商品详情
export function getLinkShopById(data) {
  return request({
    url: '/commodity/storeDetail',
    method: 'post',
    params: data
  })
}

// 获取云仓库存
export function getCloudStockById(data) {
  return request({
    url: '/commodity/goodsCloudStock',
    method: 'post',
    params: data
  })
}

// 获取软链、医柜库存
export function getGoodsStockById(data) {
  return request({
    url: '/commodity/storeGoodsStock',
    method: 'post',
    params: data
  })
}
// 门店商品详情
export function storeCommodityDetail(data) {
  return request({
    url: '/commodity/storeCommodityDetail',
    method: 'post',
    data: qs.stringify(data)
  })
}
